//
//  UILabel+Method.m
//  SchoolTask
//
//  Created by feel on 16/8/25.
//  Copyright © 2016年 sm. All rights reserved.
//

#import "UILabel+Method.h"

@implementation UILabel (Method)

//用于设置label上字体和颜色
- (NSMutableAttributedString *)setColorForLabel:(NSString *)str R:(CGFloat)r G:(CGFloat)g B:(CGFloat)b {
    
    
    NSMutableAttributedString *meTwo = [[NSMutableAttributedString alloc]initWithString:str];
    //获取要调整颜色的文字位置,调整颜色
    NSRange range1=[[meTwo string]rangeOfString:str];
    [meTwo addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1] range:range1];
    //    CGSize size = [NSString string] boundingRectWithSize:<#(CGSize)#> options:<#(NSStringDrawingOptions)#> attributes:<#(nullable NSDictionary<NSString *,id> *)#> context:<#(nullable NSStringDrawingContext *)#>;
    return meTwo;
}

@end
